﻿<UserControl x:Class="Swan.SwanWakeUp.AnalogClock"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Swan.SwanWakeUp"
             xmlns:uc="clr-namespace:Swan.SwanWakeUp.Controls"
             xmlns:customControl="clr-namespace:CustomControlLibrary;assembly=CustomControlLibrary"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <local:AlarmDateConverter x:Key="AlarmDateConverter1" />
    </UserControl.Resources>
    <StackPanel HorizontalAlignment="Center"  Width="299.97">
        <StackPanel.Resources>
            <local:SecondsConverter x:Key="secondsConverter"/>
            <local:MinutesConverter x:Key="minutesConverter"/>
            <local:HoursConverter x:Key="hoursConverter"/>
            <local:WeekdayConverter x:Key="weekdayConverter"/>
            <local:AlarmDateConverter x:Key="alarmConverter"/>
            <local:AlarmSetConverter x:Key="alarmSetConverter"/>
            <local:ColorConverter x:Key="colorConverter" />

            <Style x:Key="AnalogClock" TargetType="{x:Type customControl:AlarmClock}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type customControl:AlarmClock}">
                            <!--Control goes here-->
                            <Grid Width="300" Height="300">
                                <Image Source="Images/backGround.png"></Image>
                                <TextBlock Name="christianityCalendar" Foreground="White" 
                                    Margin="0, 0, 0, 52" HorizontalAlignment="Center" 
                                    VerticalAlignment="Bottom" Height="Auto"
                                     Width="Auto" Text="{Binding Path=DateTime, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource weekdayConverter}}"  />

                                <Label Name="lblAlarmOn" Foreground="{Binding AlarmSet, Converter={StaticResource colorConverter}}" 
                                       Margin="0, 0, 0, 75" HorizontalAlignment="Center" 
                                    VerticalAlignment="Bottom" Height="Auto"  
                                    Width="Auto" Content="{Binding AlarmSet, Converter={StaticResource alarmSetConverter}}">
                                </Label>

                                <!-- Second  -->
                                <Rectangle x:Name="SecondHand" Margin="150,0,149,150" Stroke="White" Height="120" VerticalAlignment="Bottom">
                                    <Rectangle.RenderTransform>
                                        <RotateTransform x:Name="secondHand" CenterX="0" 
                                            CenterY="120" Angle="{Binding Path=DateTime, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource secondsConverter}}"  />
                                    </Rectangle.RenderTransform>
                                </Rectangle>
                                <!---->
        
                                <!-- Minute  -->
                                <Rectangle x:Name="MinuteHand" Margin="150,49,149,151" Stroke="LightGreen">
                                    <Rectangle.RenderTransform>
                                        <RotateTransform x:Name="minuteHand" CenterX="0" CenterY="100" Angle="{Binding Path=DateTime, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource minutesConverter}}" />
                                    </Rectangle.RenderTransform>
                                </Rectangle>
                                <!---->
        
                                <!-- Hour  -->
                                <Rectangle x:Name="HourHand" Margin="150,80,149,150" Stroke="LightYellow">
                                    <Rectangle.RenderTransform>
                                        <RotateTransform x:Name="hourHand" CenterX="0" CenterY="70" Angle="{Binding Path=DateTime, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource hoursConverter}}" />
                                    </Rectangle.RenderTransform>
                                </Rectangle>

                                <!--AlarmHand-->
                                <Rectangle x:Name="AlarmHand" Margin="150,80,149,150" Stroke="Red" MinWidth="10" StrokeStartLineCap="Flat" StrokeLineJoin="Round" Width="Auto" StrokeThickness="2" RadiusX="20">
                                    <Rectangle.RenderTransform>
                                        <RotateTransform x:Name="alarmHand" CenterX="0" CenterY="70" Angle="{Binding StartTime, Converter={StaticResource AlarmDateConverter1}}"></RotateTransform>
                                    </Rectangle.RenderTransform>
                                </Rectangle>
                                <!---->
                            </Grid>           
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </StackPanel.Resources>
        <!-- The actual clockitem is added here -->
        <customControl:AlarmClock Name="alarmClock" Style="{StaticResource AnalogClock}" />
    </StackPanel>
</UserControl>
